package com.ehuoyun.ecstore.biz;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;

import com.ehuoyun.ecstore.model.Company;

@Component
public class CompanyMgr {
	@PersistenceContext
    private EntityManager em;
	
	public Company get(Long id) {
		return em.find(Company.class, id);
	}
	
	public void save(Company company) {
		em.persist(company);
	}
	
	public List<Company> search(String name) {
		return (List<Company>)em.createQuery(
				"select from com.ehuoyun.ecstore.model.Company c where c.owner = 1")
				.getResultList();
	}

}
